﻿using WeiXinPF.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WeiXinPF.Templates;

namespace WeiXinPF.Web.weixin.pano360
{
  //  public partial class index : WeiXinPage
    public partial class index : TravelBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //OnlyWeiXinLook();
            //if (!IsPostBack)
            //{
            //    wid = MyCommFun.RequestInt("wid");

            //    openid = MyCommFun.RequestOpenid();
            //    if (wid == 0)
            //    {
            //        MessageBox.Show(this, "参数不正确！");
            //        return;
            //    }
            //    litCopyRight.Text = getwebcopyright(wid);

            //    BLL.wx_pano_jd bll = new  BLL.wx_pano_jd();
            //    IList< Model.wx_pano_jd> jdlist = bll.GetModelList("wid="+wid+"  order by seq asc");
            //    if (jdlist == null || jdlist.Count <= 0)
            //    {
            //        return;
            //    }
            //    StringBuilder sb = new StringBuilder("");
            //    for (int i = 0; i < jdlist.Count; i++)
            //    {
            //        sb.Append("<li><a href=\"pano.aspx?id=" + jdlist[i].id + "\">" + jdlist[i].jdName + "</a></li>");
            //    }
            //    litpanoList.Text = sb.ToString();
            //}

            base.OnInit(e);
            if (errInitTemplates != "")
            {
                Response.Write(errInitTemplates);
                return;
            }

            //1获得模版基本信息
            BLL.wx_templates tBll = new BLL.wx_templates();
            templateFileName = tBll.GetTemplatesFileNameByWid( wid);
            if (templateFileName == null || templateFileName.Trim() == "")
            {
                errInitTemplates = "不存在该帐号或者该帐号尚未设置模版！";
                Response.Write(errInitTemplates);
                Response.End();
                return;
            }
            
            //授权
            string openid = MyCommFun.RequestOpenid();
            int categoryid = new BLL.advertisement().GetCateGoryIDbyName("travel");
            serverPath = MyCommFun.GetRootPath() + "weixin/pano360/templates/Normal/index.html";
            TravelTemplate template = new TravelTemplate("weixin/pano360/templates/", serverPath, wid, categoryid);
            template.tType = TemplateType.Index;
            //template.openid = MyCommFun.RequestOpenid();
            template.openid = openid;
            template.OutPutHtml(templateFileName,wid);

        }
    }
}